﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataAccessLayer.Models
{
    public class EnumeratedType
    {
        public static string GenderCdLbl = "SexCode";
        public static string GenderDescLbl = "Sex";
        public static IEnumerable<Gender> GenderList = null;

        public static string IDCdLbl = "IDTypeCode";
        public static string IDDescLbl = "IDTypeDesc";
        public static IEnumerable<IDType> IDList = null;

        public static string CtryCdLbl = "CountryCode";
        public static string CtryDescLbl = "CountryName";
        public static IEnumerable<Country> CtryList = null;

        public static string RelCdLbl = "RelToBorrowerCode";
        public static string RelDescLbl = "RelToBorrowerDesc";
        public static IEnumerable<Relationship> RelList = null;

        public static string STypeCdLbl = "SType";
        public static string STypeDescLbl = "SName";
        public static IEnumerable<SecurityType> STypeList = null;

        public static string TnrUnitCdLbl = "Time";
        public static string TnrUnitDescLbl = "Unit";
        public static IEnumerable<TenorUnit> TnrUnitList = null;

        public static string IntTypeCdLbl = "Code";
        public static string IntTypeDescLbl = "Desc";
        public static IEnumerable<InterestType> IntTypeList = null;

        static EnumeratedType()
        {
            LOSEntities ctx = new LOSEntities();

            GenderList = new List<Gender> 
                { 
                    new Gender {  SexCode = "M", Sex = "Male" },
                    new Gender {  SexCode = "F", Sex = "Female" },
                };


            var ids = from c in ctx.IDTypes select c;
            IDList = ids;

            var countries = from c in ctx.Countries select c;
            CtryList = countries;

            var rels = from c in ctx.Relationships select c;
            RelList = rels;

            STypeList = new List<SecurityType> 
                { 
                    new SecurityType {  SType = "PG", SName = "Personal Gurantee" },
                    new SecurityType {  SType = "FD", SName = "Fixed Deposit" },
                };

            TnrUnitList = new List<TenorUnit> 
                { 
                    new TenorUnit {  Time = "0", Unit = "Years" },
                    new TenorUnit {  Time = "1", Unit = "Months" },
                };

            IntTypeList = new List<InterestType> 
                { 
                    new InterestType {  Code = "0", Desc = "Fixed" },
                    new InterestType {  Code = "1", Desc = "Floating" },
                };

        }
    }

    public class Gender
    {
        public string SexCode { get; set; }
        public string Sex { get; set; }
    }

    public class SecurityType
    {
        public string SType { get; set; }
        public string SName { get; set; }
    }

    public class Period
    {
        public string Time { get; set; }
        public string Unit { get; set; }
    }

    public class TenorUnit : Period {}

    public class InterestType
    {
        public string Code { get; set; }
        public string Desc { get; set; }
    }
}
